//
//  SISSSellerInfoView.m
//  SISSAPP
//
//  Created by 优房网 on 2017/8/30.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSSellerInfoView.h"
#import "SISSSellerInfoModel.h"

@interface SISSSellerInfoView ()

// 发布方Label
@property (weak, nonatomic) UILabel *publisherLabel;
@property (weak, nonatomic) UILabel *publisherTitleLabel;
/// 身份证/护照号码Label
@property (weak, nonatomic) UILabel *IDCardNoLabel;
@property (weak, nonatomic) UILabel *IDCardNoTitleLabel;
/// 所占份额Label
@property (weak, nonatomic) UILabel *occupiedLabel;
@property (weak, nonatomic) UILabel *occupiedTitleLabel;
/// 通讯地址Label
@property (weak, nonatomic) UILabel *addressLabel;
@property (weak, nonatomic) UILabel *addressTitleLabel;
/// 联系电话Label
@property (weak, nonatomic) UILabel *telephoneLabel;
@property (weak, nonatomic) UILabel *telephoneTitleLabel;

/// 水印
@property (weak, nonatomic) UIImageView *waterMarkImageView;

@end
@implementation SISSSellerInfoView

- (void)setSellerInfoModel:(SISSSellerInfoModel *)sellerInfoModel {
    _sellerInfoModel = sellerInfoModel;
    
    self.publisherLabel.text = sellerInfoModel.seller_name ? sellerInfoModel.seller_name : @"";
    self.IDCardNoLabel.text = sellerInfoModel.idNo;
    self.occupiedLabel.text = [NSString stringWithFormat:@"%@%@",@(100 - sellerInfoModel.lot),@"%"];
    self.addressLabel.text = sellerInfoModel.address ? sellerInfoModel.address : @" ";
    self.telephoneLabel.text = sellerInfoModel.mobile;
}


- (void)setIsShowWaterMark:(BOOL)isShowWaterMark {
    _isShowWaterMark = isShowWaterMark;
    
    self.waterMarkImageView.hidden = !isShowWaterMark;
}


#pragma mark - UI
- (void)initUI {
    [super initUI];
    self.backgroundColor = COLOR(0xF1F1F5);
    
    UILabel *publisherTitleLabel = [[UILabel alloc] init];
    publisherTitleLabel.text = @"甲方（卖方）：";
    publisherTitleLabel.textColor = COLOR(0x8998A5);
    publisherTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:publisherTitleLabel];
    self.publisherTitleLabel = publisherTitleLabel;
    
    UILabel *publisherLabel = [[UILabel alloc] init];
    publisherLabel.text = @" ";
    publisherLabel.textColor = MAIN_TEXT_COLOR;
    publisherLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:publisherLabel];
    self.publisherLabel = publisherLabel;
    
    UILabel *IDCardNoTitleLabel = [[UILabel alloc] init];
    IDCardNoTitleLabel.text = @"身份证/护照号码/营业执照号：";
    IDCardNoTitleLabel.textColor = COLOR(0x8998A5);
    IDCardNoTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:IDCardNoTitleLabel];
    self.IDCardNoTitleLabel = IDCardNoTitleLabel;
    
    UILabel *IDCardNoLabel = [[UILabel alloc] init];
    IDCardNoLabel.text = @" ";
    IDCardNoLabel.textColor = MAIN_TEXT_COLOR;
    IDCardNoLabel.font = [UIFont boldSystemFontOfSize:15];
    IDCardNoLabel.numberOfLines = 0;
    [self addSubview:IDCardNoLabel];
    self.IDCardNoLabel = IDCardNoLabel;
    
    UILabel *occupiedTitleLabel = [[UILabel alloc] init];
    occupiedTitleLabel.text = @"所占份额：";
    occupiedTitleLabel.textColor = COLOR(0x8998A5);
    occupiedTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:occupiedTitleLabel];
    self.occupiedTitleLabel = occupiedTitleLabel;
    
    UILabel *occupiedLabel = [[UILabel alloc] init];
    occupiedLabel.text = @" ";
    occupiedLabel.textColor = MAIN_TEXT_COLOR;
    occupiedLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:occupiedLabel];
    self.occupiedLabel = occupiedLabel;
    
    UILabel *addressTitleLabel = [[UILabel alloc] init];
    addressTitleLabel.text = @"通讯地址：";
    addressTitleLabel.textColor = COLOR(0x8998A5);
    addressTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:addressTitleLabel];
    self.addressTitleLabel = addressTitleLabel;
    
    UILabel *addressLabel = [[UILabel alloc] init];
    addressLabel.text = @" ";
    addressLabel.textColor = MAIN_TEXT_COLOR;
    addressLabel.font = [UIFont boldSystemFontOfSize:15];
    addressLabel.numberOfLines = 0;
    [self addSubview:addressLabel];
    self.addressLabel = addressLabel;
    
    UILabel *telephoneTitleLabel = [[UILabel alloc] init];
    telephoneTitleLabel.text = @"联系电话：";
    telephoneTitleLabel.textColor = COLOR(0x8998A5);
    telephoneTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:telephoneTitleLabel];
    self.telephoneTitleLabel = telephoneTitleLabel;
    
    UILabel *telephoneLabel = [[UILabel alloc] init];
    telephoneLabel.text = @" ";
    telephoneLabel.textColor = MAIN_TEXT_COLOR;
    telephoneLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:telephoneLabel];
    self.telephoneLabel = telephoneLabel;
    
    UIImageView *waterMarkImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"dataWaterMark"]];
    [waterMarkImageView sizeToFit];
    waterMarkImageView.hidden = YES;
    [self addSubview:waterMarkImageView];
    
    self.waterMarkImageView = waterMarkImageView;
}

#pragma mark - 布局
- (void)initConstraint {
    [super initConstraint];
    
    WeakSelf
    CGFloat margin = 8.0;
    [self.publisherTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf).offset(margin);
        make.top.equalTo(weakSelf).offset(3 * margin);
    }];
    [self.publisherLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.publisherTitleLabel.mas_right);
        make.top.equalTo(weakSelf.publisherTitleLabel);
    }];
    
    [self.IDCardNoTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.publisherTitleLabel);
        make.top.equalTo(weakSelf.publisherTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.IDCardNoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.IDCardNoTitleLabel.mas_right);
        make.top.equalTo(weakSelf.IDCardNoTitleLabel);
        make.right.equalTo(weakSelf).offset(-margin);
    }];
    
    [self.occupiedTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.IDCardNoTitleLabel);
        make.top.equalTo(weakSelf.IDCardNoLabel.mas_bottom).offset(2 * margin);
    }];
    [self.occupiedLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.occupiedTitleLabel.mas_right);
        make.top.equalTo(weakSelf.occupiedTitleLabel);
        make.right.equalTo(weakSelf).offset(-margin);
    }];
    
    [self.addressTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.occupiedTitleLabel);
        make.top.equalTo(weakSelf.occupiedTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.addressTitleLabel.mas_right);
        make.top.equalTo(weakSelf.addressTitleLabel);
        make.right.equalTo(weakSelf).offset(-margin);
    }];
    
    [self.telephoneTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.addressTitleLabel);
        make.top.equalTo(weakSelf.addressLabel.mas_bottom).offset(2 * margin);
    }];
    [self.telephoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.telephoneTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.telephoneTitleLabel);
        make.bottom.equalTo(weakSelf).offset(-margin);
    }];
    
    [self.waterMarkImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(weakSelf);
    }];
}


@end

